import axios from 'axios';
import qs from 'query-string';

export interface VipSolutionId {
    id: number;
}

export interface VipSolutionRecord {
    id: number;
    name: string;
    description: string;
    money: number;
    days: number;
    status: string;
    created_at: number;
    updated_at: number;
}

export interface VipSolutionListRes {
    list: VipSolutionRecord[];
    total: number;
}

export interface VipSolutionModel {
    id: number;
    name: string;
    description: string;
    money: number;
    days: number;
    status: string;
}

export interface VipDetailRecord {
    id: number;
    icon: string;
    name: string;
    sub_name: string;
    description: string;
    created_at: number;
    updated_at: number;
}

export interface VipDetailListRes {
    list: VipDetailRecord[];
    total: number;
}

export interface VipDetailModel {
    id: number;
    icon: string;
    name: string;
    sub_name: string;
    description: string;
}

export interface VipDetailParams extends Partial<VipDetailRecord> {
    page: number;
    pageSize: number;
}

export interface VipSolutionParams extends Partial<VipSolutionRecord> {
    page: number;
    pageSize: number;
}

/**
 * 获取VIP方案列表
 * @param params
 */
export function queryVipSolutionList(params: VipSolutionParams) {
    return axios.get<VipSolutionListRes>('/admin/vipSolution/index', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 获取VIP方案详情
 * @param params
 */
export function queryVipSolutionOne(params: VipSolutionId) {
    return axios.get<VipSolutionRecord>('/admin/vipSolution/detail', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 提交VIP方案表单（创建/更新）
 * @param data
 */
export function submitVipSolutionForm(data: any) {
    return axios.post('/admin/vipSolution/submit', data);
}

/**
 * 删除VIP方案
 * @param id
 */
export function delVipSolution(id: number) {
    return axios.post('/admin/vipSolution/delete', { id });
}

/**
 * 获取VIP权益列表
 * @param params
 */
export function queryVipDetailList(params: VipDetailParams) {
    return axios.get<VipDetailListRes>('/admin/vipSolution/vipDetailList', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 获取VIP权益详情
 * @param params
 */
export function queryVipDetailOne(params: VipSolutionId) {
    return axios.get<VipDetailRecord>('/admin/vipSolution/vipDetailDetail', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 提交VIP权益表单（创建/更新）
 * @param data
 */
export function submitVipDetailForm(data: any) {
    return axios.post('/admin/vipSolution/submitVipDetail', data);
}

/**
 * 删除VIP权益
 * @param id
 */
export function delVipDetail(id: number) {
    return axios.post('/admin/vipSolution/deleteVipDetail', { id });
} 